*Created in Stata/SE 16.1


********************************************************************************

* Define the main directory
global main="****YOUR DIRECTORY HERE*****"

* Define data directory
global data="**DATA FOLDER HERE**"

* Define figures directory
global figures="**FIGURES AND TABLES FOLDER HERE"

********************************************************************************
*Import Data*
********************************************************************************

cd "$data"
use "PRQReplicationData.dta", clear

********************************************************************************
*Analysis- Main Paper*
********************************************************************************

******************
*****Table 1******
******************
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="North", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="South", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="West", cluster (stateid)


******************
*****Figure 1*****
******************
preserve

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 , cluster (stateid)

margins, at (log_rob_prog_3=(0 2.3025851 2.9957323 3.4011974 3.6888795 3.912023 4.0943446 4.2484952 4.3820266 4.4998097 4.6051702)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save ProgressiveStrength, replace

restore


******************
*****Figure 2*****
******************

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)

margins, at (deltaurban=(-2(.05)1.5))

marginsplot, xscale(range(-2 1.5)) xlabel(-2(.5)1.5, nogrid) ylabel(,nogrid) ymtick(##5, nogrid) recastci(rline) ciopts(lpattern(dash)) recast(line) ytitle("Probability of Adoption of Primary") xtitle ("Change in Urban Population") title("") 

cd "$figures"
graph save UrbanGrowth, replace



********************************************************************************
*Analysis- Appendix*
********************************************************************************


******************
*****Table 1A*****
******************

stset year, failure(primary_adoption_strict =1)

stcox deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev if year>1891
stcox deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev if year>1891 & region_4_catBorder =="North"
stcox deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev if year>1891 & region_4_catBorder =="South"
stcox deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev if year>1891 & region_4_catBorder =="West"

******************
*****Table 2A*****
******************

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year1 year1sq if year>1891, cluster (stateid) 
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year1 year1sq if year>1891 & region_4_catBorder =="North", cluster (stateid) 
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year1 year1sq if year>1891 & region_4_catBorder =="South", cluster (stateid) 
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year1 year1sq if year>1891 & region_4_catBorder =="West", cluster (stateid) 

******************
*****Table 3A*****
******************

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev lnyear if year>1891, cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev lnyear if year>1891 & region_4_catBorder =="North", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev lnyear if year>1891 & region_4_catBorder =="South", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev lnyear if year>1891 & region_4_catBorder =="West", cluster (stateid)

******************
*****Table 4A*****
******************

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev i.fiveyear if year>1891, cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev i.fiveyear if year>1891 & region_4_catBorder =="North", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev i.fiveyear if year>1891 & region_4_catBorder =="South", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev i.fiveyear if year>1891 & region_4_catBorder =="West", cluster (stateid) 

******************
*****Table 5A*****
******************

probit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)
probit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="North", cluster (stateid)
probit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="South", cluster (stateid)
probit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="West", cluster (stateid)

******************
*****Table 6A*****
******************

cloglog primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)
cloglog primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="North", cluster (stateid)
cloglog primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="South", cluster (stateid)
cloglog primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="West", cluster (stateid)

******************
*****Figure 1A****
******************

preserve

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="North", cluster (stateid)
margins, at (log_rob_prog_3=(0 2.3025851 2.9957323 3.4011974 3.6888795 3.912023 4.0943446 4.2484952 4.3820266 4.4998097 4.6051702)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save ProgressiveStrengthNorth, replace
restore

******************
*****Figure 2A****
******************

preserve

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="South", cluster (stateid)
margins, at (log_rob_prog_3=(0 2.3025851 2.9957323 3.4011974 3.6888795 3.912023 4.0943446 4.2484952 4.3820266 4.4998097 4.6051702)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save ProgressiveStrengthSouth, replace
restore

******************
*****Figure 3A****
******************

preserve

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="West", cluster (stateid)
margins, at (log_rob_prog_3=(0 2.3025851 2.9957323 3.4011974 3.6888795 3.912023 4.0943446 4.2484952 4.3820266 4.4998097 4.6051702)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save ProgressiveStrengthWest, replace
restore

******************
*****Table 7A*****
******************

logit primary_adoption_strict deltaurban one_party_sw_3 logpopulist92 imp_income borderadoptedprev year if year>1891, cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 populist92 imp_income borderadoptedprev year if year>1891, cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 p_house_pct_max imp_income borderadoptedprev year if year>1891, cluster (stateid)

******************
*****Figure 4A****
******************

preserve

logit primary_adoption_strict deltaurban one_party_sw_3 logpopulist92 imp_income borderadoptedprev year if year>1891, cluster (stateid)
margins, at (logpopulist92=(0 2.3025851 2.9957323 3.4011974 3.6888795 3.912023 4.0943446 4.2484952 4.3820266 4.4998097 4.6051702)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
replace _ci_ub=. if _ci_ub>.15
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(0(.05).15,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save LogPopStrength, replace

restore

******************
*****Figure 5A****
******************

preserve

logit primary_adoption_strict deltaurban one_party_sw_3 populist92 imp_income borderadoptedprev year if year>1891, cluster (stateid)
margins, at (populist92=(0 10 20 30 40 50 60 70 80 90 100)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
replace _ci_ub=. if _ci_ub>.15
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(0(.05).15,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save PopStrength, replace
restore

******************
*****Figure 6A****
******************

preserve

logit primary_adoption_strict deltaurban one_party_sw_3 p_house_pct_max imp_income borderadoptedprev year if year>1891, cluster (stateid)
margins, at (p_house_pct_max=(0 .10 .20 .30 .40 .50 .60 .70 .80 .90 .100)) saving("tmp", replace) 

use "tmp", clear
gen value=_at*10-10
replace _ci_ub=. if _ci_ub>.15
tw (line _margin value, lcolor(black) leg(off) ytitle("Probability of Adoption of Primary") xtitle("Strength of Progressive Movement") ymtick(##5, nogrid) xlabel(,nogrid) ylabel(0(.05).15,nogrid)) (line _ci_lb value, lpattern(dash) lcolor(gs8))(line _ci_ub value, lpattern(dash) lcolor(gs8))

cd "$figures"
graph save PolReformersHouseStrength, replace
restore


******************
*****Table 8A*****
******************

logit primary_adoption_strict c.deltaurban##c.log_rob_prog_3  one_party_sw_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)
logit primary_adoption_strict c.deltaurban##c.log_rob_prog_3  one_party_sw_3 imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="North", cluster (stateid)


******************
*****Table 9A*****
******************

logit primary_adoption_strict i.one_party_sw_3##c.log_rob_prog_3  c.deltaurban imp_income borderadoptedprev year if year>1891, cluster (stateid)
logit primary_adoption_strict i.one_party_sw_3##c.log_rob_prog_3  c.deltaurban imp_income borderadoptedprev year if year>1891 & region_4_catBorder =="North", cluster (stateid)

******************
*****Table 10A****
******************

logit primary_adoption_strict deltaurban control_loss_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)

******************
*****Table 11A****
******************

logit primary_adoption_strict d.imp_population one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & year!=1892 & year!=1893 & year!=1894 & year!=1895 & year!=1896 & year!=1897 & year!=1898 & year!=1899 & year!=1900, cluster (stateid)

logit primary_adoption_strict imp_population one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & year!=1892 & year!=1893 & year!=1894 & year!=1895 & year!=1896 & year!=1897 & year!=1898 & year!=1899, cluster (stateid)

******************
*****Table 12A****
******************

logit primary_adoption_strict d.imp_population one_party_sw_3 logpopulist92 imp_income borderadoptedprev year if year>1891 & year!=1892 & year!=1893 & year!=1894 & year!=1895 & year!=1896 & year!=1897 & year!=1898 & year!=1899 & year!=1900, cluster (stateid)

logit primary_adoption_strict imp_population one_party_sw_3 logpopulist92 imp_income borderadoptedprev year if year>1891 & year!=1892 & year!=1893 & year!=1894 & year!=1895 & year!=1896 & year!=1897 & year!=1898 & year!=1899, cluster (stateid)

******************
*****Table 13A****
******************

logit primary_adoption_strict d.imp_population one_party_sw_3 p_house_pct_max imp_income borderadoptedprev year if year>1891 & year!=1892 & year!=1893 & year!=1894 & year!=1895 & year!=1896 & year!=1897 & year!=1898 & year!=1899 & year!=1900, cluster (stateid)

logit primary_adoption_strict imp_population one_party_sw_3 p_house_pct_max imp_income borderadoptedprev year if year>1891 & year!=1892 & year!=1893 & year!=1894 & year!=1895 & year!=1896 & year!=1897 & year!=1898 & year!=1899, cluster (stateid)


******************
*****Table 14A****
******************

logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891, cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catConfed =="North", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catConfed =="South", cluster (stateid)
logit primary_adoption_strict deltaurban one_party_sw_3 log_rob_prog_3 imp_income borderadoptedprev year if year>1891 & region_4_catConfed =="West", cluster (stateid)
